<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org/">
<head>
    <title>Title</title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <script src="/layui/layui.js"></script>
    <script src="/layui/js/iSlider.min.js"></script>
    <script src="/layui/js/iSlider.plugin.dot.min.js"></script>
    <script src="/layui/js/zepto.min.js"></script>

</head>
<body>
aaaaaaaaaaaaaaaaaaaaaaaaaaaa
<div id="dept_tree">

</div>
</body>
<script>

    layui.use(['tree','util'],function () {
        var tree=layui.tree;
        var util=layui.util;
        tree.render({
            elem:'#dept_tree',
            data:getData(),
            id:"treeId",
            showCheckbox:true,
            onlyIconControl:true
        });

//        var inst1 = tree.render({
//            elem: '#dept_tree'  //绑定元素
//            ,data: [{
//                title: '江西' //一级菜单
//                ,children: [{
//                    title: '南昌' //二级菜单
//                    ,children: [{
//                        title: '高新区' //三级菜单
//                        //…… //以此类推，可无限层级
//                    }]
//                }]
//            },{
//                title: '陕西' //一级菜单
//                ,children: [{
//                    title: '西安' //二级菜单
//                }]
//            }]
//        });
    });


    function getData() {

        var data=[];
        $.ajax({
            url:"provinces/treeload",
            type:"post",
            async:false,
            success:function (result) {
                data=result;
            }
        });
        return data;
    }
</script>
</html>